import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {HttpModule} from '@angular/http';
import {RouterModule, Routes} from '@angular/router';

import {AppComponent} from './app.component';
import {SmarketHttpService} from './services/smarket-http.service';
import {ArticleListService} from './services/article-list.service';
import {HomeComponent} from './home/home.component';
import {SearchComponent} from './search/search.component';
import {ArticleComponent} from './article/article.component';
import {AppService} from './services/app.service';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';

const routeConfig: Routes = [
  {path: 'articles/:parentArticleCategoryId', component: HomeComponent},
  {path: 'article/:articleId', component: ArticleComponent},
  {path: '**', redirectTo: 'articles/0', pathMatch: 'full'}
];

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    SearchComponent,
    ArticleComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    HttpModule,
    RouterModule.forRoot(routeConfig)
  ],
  providers: [
    SmarketHttpService, ArticleListService, AppService, {
      provide: LocationStrategy,
      useClass: HashLocationStrategy
    }],
  bootstrap: [AppComponent]
})
export class AppModule {
}
